#ifndef INC_CCONFIG_H_
#define INC_CCONFIG_H_

#include <string>
#include <Poco/Mutex.h>
#include <Poco/Net/SocketAddress.h>

#define DEFAULT_NET_INTERFACE "wlan0"
#define DEFAULT_MULTICAST_GROUP "239.0.0.2:4000"
#define DEFAULT_NAMESERVER_DELAY "25000"
#define DEFAULT_MAXPACKET_SIZE 32768
/*********************************************************/
class cConfig
{
private:
	// Members
	static cConfig& 			pInstance;	// Only available instance of config
	static Poco::Mutex*			mutex;		// Mutual exclusion object for multithreading security
	
	// Configuration parameters
	Poco::Net::SocketAddress		pMulticastGroup;
	std::string				pNetworkInterface;
	std::string				pRingName;
	unsigned long				pMaxPacketSize;
	unsigned int				pNameServerDelay;

	// Methods
	void writeDefaultConfig();
	bool parse();

	// Copy Construction/Assignment operator
	cConfig();						// Constructor
	cConfig( const cConfig& );				// Copy Constructor
	cConfig& operator=(const cConfig&);			// Assignment operator

protected:
public:
	// Methods for retrieval of configuration parameters
	Poco::Net::SocketAddress getMulticastGroup() const;
	unsigned int getNameServerDelay() const;	
	std::string getNetworkInterface() const;
	std::string getRingName() const;
	unsigned long getMaxPacketSize() const;

	// Methods for setting configuration parameters
	void setNetworkInterface(const std::string&);
	void setMulticastGroup(const Poco::Net::SocketAddress&);
	void setNameServerDelay(const unsigned int&);
	void setRingName(const std::string&);
	void setMaxPacketSize(const unsigned long&);

	// Methods to reinitialize ( reparsing the config.ini file )
	void reparse();

	// Construction & Destruction
	static cConfig& Instance();				// Instance retrieval method
	virtual ~cConfig();					// Destructor
};
/*********************************************************/
#endif // INC_CCONFIG_H_
